package fr.adama.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author mini-john
 */
@Controller
public class IndexController {

    @Value("${application.version}")
    String versionApplication;
    
    @ModelAttribute("versionApplication")
    public String getVersionApplication() {
        return versionApplication;
    }


    private static final Logger logger = Logger.getLogger(IndexController.class);

    
   

    @RequestMapping("/index.do")
    public ModelAndView index(HttpServletRequest request) {
        logger.info("je suis dans l'index");
        request.getSession(true).setAttribute("versionApplication", versionApplication);
        return new ModelAndView("home/index");
    }
    @RequestMapping("/login.do")
    public ModelAndView login(HttpServletRequest request) {
        logger.info("je suis dans l'index");
        request.getSession(true).setAttribute("versionApplication", versionApplication);
        return new ModelAndView("/login");
    }
}
